<-- back

Excel Sheet Column Title\

Link

Used the same strategy for breaking apart digits for this. Nothing too surprising.

Full Solution in Java:

public class Solution { public String convertToTitle(int n) { StringBuilder sb= new StringBuilder(); while(n!=0){ int x = n%26; if(x==0){ sb.append("Z"); n-=26; } else{ char c = (char)(x+64); sb.append(c); } n/=26; } return sb.reverse().toString(); } }